<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
    <el-form-item label="接收时间" prop="recvtime">
      <el-input v-model="dataForm.recvtime" placeholder="接收时间"></el-input>
    </el-form-item>
    <el-form-item label="登记中心号" prop="bdcno">
      <el-input v-model="dataForm.bdcno" placeholder="登记中心号"></el-input>
    </el-form-item>
    <el-form-item label="接收网点号" prop="obankid">
      <el-input v-model="dataForm.obankid" placeholder="接收网点号"></el-input>
    </el-form-item>
    <el-form-item label="接收参与者号" prop="bankid">
      <el-input v-model="dataForm.bankid" placeholder="接收参与者号"></el-input>
    </el-form-item>
    <el-form-item label="区划代码" prop="region">
      <el-input v-model="dataForm.region" placeholder="区划代码"></el-input>
    </el-form-item>
    <el-form-item label="提示编码" prop="tipcode">
      <el-input v-model="dataForm.tipcode" placeholder="提示编码"></el-input>
    </el-form-item>
    <el-form-item label="提示描述" prop="tipdesc">
      <el-input v-model="dataForm.tipdesc" placeholder="提示描述"></el-input>
    </el-form-item>
    <el-form-item label="业务标识码" prop="servicecode">
      <el-input v-model="dataForm.servicecode" placeholder="业务标识码"></el-input>
    </el-form-item>
    <el-form-item label="不动产登记证明号" prop="realtyno">
      <el-input v-model="dataForm.realtyno" placeholder="不动产登记证明号"></el-input>
    </el-form-item>
    <el-form-item label="业务件号" prop="serviceno">
      <el-input v-model="dataForm.serviceno" placeholder="业务件号"></el-input>
    </el-form-item>
    <el-form-item label="受理号" prop="slh">
      <el-input v-model="dataForm.slh" placeholder="受理号"></el-input>
    </el-form-item>
    <el-form-item label="查封机构" prop="cfjg">
      <el-input v-model="dataForm.cfjg" placeholder="查封机构"></el-input>
    </el-form-item>
    <el-form-item label="查封时间" prop="cfsj">
      <el-input v-model="dataForm.cfsj" placeholder="查封时间"></el-input>
    </el-form-item>
    <el-form-item label="解封机构" prop="jfjg">
      <el-input v-model="dataForm.jfjg" placeholder="解封机构"></el-input>
    </el-form-item>
    <el-form-item label="解封时间" prop="jfsj">
      <el-input v-model="dataForm.jfsj" placeholder="解封时间"></el-input>
    </el-form-item>
    <el-form-item label="状态码" prop="status">
      <el-input v-model="dataForm.status" placeholder="状态码"></el-input>
    </el-form-item>
    <el-form-item label="状态码描述" prop="descinfo">
      <el-input v-model="dataForm.descinfo" placeholder="状态码描述"></el-input>
    </el-form-item>
    <el-form-item label="备注:预转本填预转本类型" prop="remark">
      <el-input v-model="dataForm.remark" placeholder="备注:预转本填预转本类型"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          seqno: 0,
          recvtime: '',
          bdcno: '',
          obankid: '',
          bankid: '',
          region: '',
          tipcode: '',
          tipdesc: '',
          servicecode: '',
          realtyno: '',
          serviceno: '',
          slh: '',
          cfjg: '',
          cfsj: '',
          jfjg: '',
          jfsj: '',
          status: '',
          descinfo: '',
          remark: ''
        },
        dataRule: {
          recvtime: [
            { required: true, message: '接收时间不能为空', trigger: 'blur' }
          ],
          bdcno: [
            { required: true, message: '登记中心号不能为空', trigger: 'blur' }
          ],
          obankid: [
            { required: true, message: '接收网点号不能为空', trigger: 'blur' }
          ],
          bankid: [
            { required: true, message: '接收参与者号不能为空', trigger: 'blur' }
          ],
          region: [
            { required: true, message: '区划代码不能为空', trigger: 'blur' }
          ],
          tipcode: [
            { required: true, message: '提示编码不能为空', trigger: 'blur' }
          ],
          tipdesc: [
            { required: true, message: '提示描述不能为空', trigger: 'blur' }
          ],
          servicecode: [
            { required: true, message: '业务标识码不能为空', trigger: 'blur' }
          ],
          realtyno: [
            { required: true, message: '不动产登记证明号不能为空', trigger: 'blur' }
          ],
          serviceno: [
            { required: true, message: '业务件号不能为空', trigger: 'blur' }
          ],
          slh: [
            { required: true, message: '受理号不能为空', trigger: 'blur' }
          ],
          cfjg: [
            { required: true, message: '查封机构不能为空', trigger: 'blur' }
          ],
          cfsj: [
            { required: true, message: '查封时间不能为空', trigger: 'blur' }
          ],
          jfjg: [
            { required: true, message: '解封机构不能为空', trigger: 'blur' }
          ],
          jfsj: [
            { required: true, message: '解封时间不能为空', trigger: 'blur' }
          ],
          status: [
            { required: true, message: '状态码不能为空', trigger: 'blur' }
          ],
          descinfo: [
            { required: true, message: '状态码描述不能为空', trigger: 'blur' }
          ],
          remark: [
            { required: true, message: '备注:预转本填预转本类型不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      init (id) {
        this.dataForm.seqno = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.seqno) {
            this.$http({
              url: this.$http.adornUrl(`/bdc/bdcpushmessage/info/${this.dataForm.seqno}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.recvtime = data.bdcPushmessage.recvtime
                this.dataForm.bdcno = data.bdcPushmessage.bdcno
                this.dataForm.obankid = data.bdcPushmessage.obankid
                this.dataForm.bankid = data.bdcPushmessage.bankid
                this.dataForm.region = data.bdcPushmessage.region
                this.dataForm.tipcode = data.bdcPushmessage.tipcode
                this.dataForm.tipdesc = data.bdcPushmessage.tipdesc
                this.dataForm.servicecode = data.bdcPushmessage.servicecode
                this.dataForm.realtyno = data.bdcPushmessage.realtyno
                this.dataForm.serviceno = data.bdcPushmessage.serviceno
                this.dataForm.slh = data.bdcPushmessage.slh
                this.dataForm.cfjg = data.bdcPushmessage.cfjg
                this.dataForm.cfsj = data.bdcPushmessage.cfsj
                this.dataForm.jfjg = data.bdcPushmessage.jfjg
                this.dataForm.jfsj = data.bdcPushmessage.jfsj
                this.dataForm.status = data.bdcPushmessage.status
                this.dataForm.descinfo = data.bdcPushmessage.descinfo
                this.dataForm.remark = data.bdcPushmessage.remark
              }
            })
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/bdc/bdcpushmessage/${!this.dataForm.seqno ? 'save' : 'update'}`),
              method: 'post',
              data: this.$http.adornData({
                'seqno': this.dataForm.seqno || undefined,
                'recvtime': this.dataForm.recvtime,
                'bdcno': this.dataForm.bdcno,
                'obankid': this.dataForm.obankid,
                'bankid': this.dataForm.bankid,
                'region': this.dataForm.region,
                'tipcode': this.dataForm.tipcode,
                'tipdesc': this.dataForm.tipdesc,
                'servicecode': this.dataForm.servicecode,
                'realtyno': this.dataForm.realtyno,
                'serviceno': this.dataForm.serviceno,
                'slh': this.dataForm.slh,
                'cfjg': this.dataForm.cfjg,
                'cfsj': this.dataForm.cfsj,
                'jfjg': this.dataForm.jfjg,
                'jfsj': this.dataForm.jfsj,
                'status': this.dataForm.status,
                'descinfo': this.dataForm.descinfo,
                'remark': this.dataForm.remark
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>
